import React from "react";
import { NavBar } from "antd-mobile";
// 导入props校验的包
import PropTypes from 'prop-types'
import {withRouter} from 'react-router-dom'
import './index.scss'
import style from './index.module.css'

const NavHeader = ({children,history,onLeftClick}) => {

    //默认点击行为
    const defaultHandler=()=>{
        history.go(-1)
    } 

	return (
		<NavBar
			className={style.navBar}
			mode="light"
			icon={<i className="iconfont icon-back"></i>}
			onLeftClick={onLeftClick || defaultHandler}
		>
			{children}
		</NavBar>
	);
};

NavHeader.propTypes={
    children:PropTypes.string.isRequired,
    onLeftClick:PropTypes.func

}
export default withRouter(NavHeader);
